<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>IFOnlyRT:  Fichier source de /home/digitalguru/IFOnlyRT$/IFOnlyRT/Basics/CVector2.hpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Généré par Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Page&nbsp;principale</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Fichiers</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Liste&nbsp;des&nbsp;fichiers</span></a></li>
    </ul>
  </div>
<h1>/home/digitalguru/IFOnlyRT$/IFOnlyRT/Basics/CVector2.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CVECTOR2_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CVECTOR2_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span><span class="comment">// Copyright (C) 2002 IFOnlyRT Project.</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="comment">// This program is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment">// the Free Software Foundation, version 2.0.</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00010"></a>00010 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00011"></a>00011 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00012"></a>00012 <span class="comment">// GNU General Public License 2.0 for more details.</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="comment">// A copy of the GPL 2.0 should have been included with the program.</span>
<a name="l00015"></a>00015 <span class="comment">// If not, see http://www.gnu.org/licenses/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="comment">// Official SVN repository and contact information can be found at</span>
<a name="l00018"></a>00018 <span class="comment">// http://code.google.com/p/ifonlyrt/</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="comment">/*</span>
<a name="l00021"></a>00021 <span class="comment"> * CVector2.hpp</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> *  Created on: 15 oct. 2009</span>
<a name="l00024"></a>00024 <span class="comment"> *      Author: Maxime Gaudin</span>
<a name="l00025"></a>00025 <span class="comment"> */</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#ifndef UINT</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>        <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> uint;
<a name="l00031"></a>00031 <span class="preprocessor">        #define UINT</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00037"></a>00037 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00038"></a><a class="code" href="classCVector2__NumbersOnly.html">00038</a> <span class="keyword">class </span><a class="code" href="classCVector2__NumbersOnly.html">CVector2_NumbersOnly</a>
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040         <span class="keyword">private</span>:
<a name="l00041"></a>00041                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">int</span>&amp;                            i )<span class="keyword"> const</span>{ }
<a name="l00042"></a>00042                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> uint&amp;                           i )<span class="keyword"> const</span>{ }
<a name="l00043"></a>00043                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">char</span>&amp;                           i)<span class="keyword"> const</span>{ }
<a name="l00044"></a>00044                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>&amp;          i)<span class="keyword"> const</span>{ }
<a name="l00045"></a>00045 
<a name="l00046"></a>00046                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">double</span>&amp;                         i)<span class="keyword"> const</span>{ }
<a name="l00047"></a>00047                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">long</span>&amp;                           i)<span class="keyword"> const</span>{ }
<a name="l00048"></a>00048                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">float</span>&amp;                          i)<span class="keyword"> const</span>{ }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050         <span class="keyword">public</span>:
<a name="l00051"></a>00051                 <a class="code" href="classCVector2__NumbersOnly.html">CVector2_NumbersOnly</a>()
<a name="l00052"></a>00052             {
<a name="l00053"></a>00053                T valid;
<a name="l00054"></a>00054                ValidateType(valid);
<a name="l00055"></a>00055             };
<a name="l00056"></a>00056 };
<a name="l00057"></a>00057 
<a name="l00062"></a>00062 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T = <span class="keywordtype">double</span>&gt;
<a name="l00063"></a><a class="code" href="classCVector2.html">00063</a> <span class="keyword">class </span><a class="code" href="classCVector2.html">CVector2</a> {
<a name="l00064"></a>00064         <span class="keyword">public</span>:
<a name="l00069"></a><a class="code" href="classCVector2.html#b172de535c6851c64fbf3355a8ee3d81">00069</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#b172de535c6851c64fbf3355a8ee3d81">Zero</a>;
<a name="l00070"></a>00070 
<a name="l00075"></a><a class="code" href="classCVector2.html#8a1b86cf6dea2364928ccf7c11496903">00075</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#8a1b86cf6dea2364928ccf7c11496903">One</a>;
<a name="l00076"></a>00076 
<a name="l00077"></a>00077         <span class="keyword">public</span>:
<a name="l00082"></a>00082                 <a class="code" href="classCVector2.html#25313de2a839679fe62282c35f15d5f8">CVector2</a>();
<a name="l00083"></a>00083 
<a name="l00087"></a>00087                 <a class="code" href="classCVector2.html#25313de2a839679fe62282c35f15d5f8">CVector2</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; Copy);
<a name="l00088"></a>00088 
<a name="l00094"></a>00094                 <a class="code" href="classCVector2.html#25313de2a839679fe62282c35f15d5f8">CVector2</a>(<span class="keyword">const</span> T&amp; vX, <span class="keyword">const</span> T&amp; vY);
<a name="l00095"></a>00095 
<a name="l00100"></a>00100                 <a class="code" href="classCVector2.html#25313de2a839679fe62282c35f15d5f8">CVector2</a>(<span class="keyword">const</span> T&amp; Value);
<a name="l00101"></a>00101 
<a name="l00102"></a>00102         <span class="keyword">public</span>:
<a name="l00107"></a>00107                 T                               <a class="code" href="classCVector2.html#b6b7aaddd96c2a3bbb47daaab1fb7ef2">GetModulus</a>() <span class="keyword">const</span>;
<a name="l00108"></a>00108 
<a name="l00114"></a>00114                 T                               <a class="code" href="classCVector2.html#44a70eb4da431c74c813e86298e580ee">GetSquaredModulus</a>() <span class="keyword">const</span>;
<a name="l00115"></a>00115 
<a name="l00120"></a>00120                 <span class="keywordtype">void</span>                    <a class="code" href="classCVector2.html#df5870d345b064343d0f3fd249c1af0c">Normalize</a>();
<a name="l00121"></a>00121 
<a name="l00125"></a>00125                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>     <a class="code" href="classCVector2.html#189caf5c2ae8301e53cd45aa13786158">GetNormalized</a>() <span class="keyword">const</span>;
<a name="l00126"></a>00126 
<a name="l00127"></a>00127         <span class="keyword">public</span>:
<a name="l00133"></a><a class="code" href="classCVector2.html#a744c9c8839ce90dff90df3c5783cadb">00133</a>                 <span class="keyword">static</span> T <a class="code" href="classCVector2.html#a744c9c8839ce90dff90df3c5783cadb">Dot</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V2)
<a name="l00134"></a>00134                 { <span class="keywordflow">return</span> V1.<a class="code" href="classCVector2.html#8af35f00b4fe14bc4a38f6307815b345">X</a> * V2.<a class="code" href="classCVector2.html#8af35f00b4fe14bc4a38f6307815b345">X</a> + V1.<a class="code" href="classCVector2.html#ce81ef6e58dfbc8bfc6a8a65a80d6b43">Y</a> * V2.<a class="code" href="classCVector2.html#ce81ef6e58dfbc8bfc6a8a65a80d6b43">Y</a>; }
<a name="l00135"></a>00135 
<a name="l00136"></a>00136         <span class="keyword">public</span>:
<a name="l00141"></a>00141                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#f1bce3115171d4339dd01869507123b0">operator =</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V2);
<a name="l00142"></a>00142 
<a name="l00147"></a>00147                 T <a class="code" href="classCVector2.html#bbab39aa64ac6745169fecb00afab745">operator []</a>(<span class="keyword">const</span> uint i);
<a name="l00148"></a>00148 
<a name="l00153"></a>00153                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#0c88135bcc5765b5b9c51a94288a6678">operator +</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V2);
<a name="l00154"></a>00154 
<a name="l00159"></a>00159                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#9e00d607efdc27b433b5500798a5f42c">operator +=</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V2);
<a name="l00160"></a>00160 
<a name="l00165"></a>00165                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#f08b687ba5a89b6e1e3629aa45372ad5">operator -</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V2);
<a name="l00166"></a>00166 
<a name="l00171"></a>00171                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#18ded90e51b0c350ab78e8b4315d8dc9">operator -=</a>(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V2);
<a name="l00172"></a>00172 
<a name="l00177"></a>00177                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#b73a38dc9707f72f9846dfa30a80f14e">operator *</a>(<span class="keyword">const</span> T Scalar);
<a name="l00178"></a>00178 
<a name="l00183"></a>00183                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#02d5706206b31f45721bb144416347f3">operator *=</a>(<span class="keyword">const</span> T Scalar);
<a name="l00184"></a>00184 
<a name="l00189"></a>00189                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#89249e791cb4edb7ebf110f78ce590de">operator /</a>(<span class="keyword">const</span> T Scalar);
<a name="l00190"></a>00190 
<a name="l00195"></a>00195                 <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a> <a class="code" href="classCVector2.html#692f6a9a9c3257be5277844cfad4eccd">operator /=</a>(<span class="keyword">const</span> T Scalar);
<a name="l00196"></a>00196 
<a name="l00197"></a>00197         <span class="keyword">public</span>:
<a name="l00202"></a><a class="code" href="classCVector2.html#8af35f00b4fe14bc4a38f6307815b345">00202</a>                 T <a class="code" href="classCVector2.html#8af35f00b4fe14bc4a38f6307815b345">X</a>;
<a name="l00203"></a>00203 
<a name="l00208"></a><a class="code" href="classCVector2.html#ce81ef6e58dfbc8bfc6a8a65a80d6b43">00208</a>                 T <a class="code" href="classCVector2.html#ce81ef6e58dfbc8bfc6a8a65a80d6b43">Y</a>;
<a name="l00209"></a>00209 };
<a name="l00210"></a>00210 
<a name="l00215"></a>00215 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;
<a name="l00216"></a>00216 <span class="keywordtype">bool</span> operator ==(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;U&gt;</a>&amp; V2)
<a name="l00217"></a>00217 {
<a name="l00218"></a>00218         <span class="keywordflow">if</span>(V1.<a class="code" href="classCVector2.html#8af35f00b4fe14bc4a38f6307815b345">X</a> != V2.<a class="code" href="classCVector2.html#8af35f00b4fe14bc4a38f6307815b345">X</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00219"></a>00219         <span class="keywordflow">if</span>(V1.<a class="code" href="classCVector2.html#ce81ef6e58dfbc8bfc6a8a65a80d6b43">Y</a> != V2.<a class="code" href="classCVector2.html#ce81ef6e58dfbc8bfc6a8a65a80d6b43">Y</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00220"></a>00220 
<a name="l00221"></a>00221         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223 
<a name="l00228"></a>00228 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;
<a name="l00229"></a>00229 <span class="keywordtype">bool</span> operator !=(<span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector2.html">CVector2&lt;U&gt;</a>&amp; V2)
<a name="l00230"></a>00230 {
<a name="l00231"></a>00231         <span class="keywordflow">return</span> !(V1 == V2);
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233 
<a name="l00238"></a>00238 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
<a name="l00239"></a>00239 std::ostream&amp; operator&lt;&lt;(std::ostream&amp; outStream,const CVector2&lt;T&gt;&amp; V1)
<a name="l00240"></a>00240 {
<a name="l00241"></a>00241         outStream &lt;&lt; std::string(<span class="stringliteral">"{X = "</span>);
<a name="l00242"></a>00242         outStream &lt;&lt; V1.X &lt;&lt; <span class="stringliteral">", Y = "</span>;
<a name="l00243"></a>00243         outStream &lt;&lt; V1.Y &lt;&lt; <span class="stringliteral">", "</span>;
<a name="l00244"></a>00244         outStream &lt;&lt; V1.GetModulus() &lt;&lt; <span class="stringliteral">"}"</span>;
<a name="l00245"></a>00245         <span class="keywordflow">return</span> outStream;
<a name="l00246"></a>00246 }
<a name="l00247"></a>00247 <span class="preprocessor">#endif </span><span class="comment">/* CVECTOR2_H */</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Généré le Thu Oct 22 19:37:51 2009 pour IFOnlyRT par&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>
